How to pass a scenario outlines with different parameters? - loops

I am using behave to do my tests.
I want to play my scenario outlines with others parameters, a scenario outlines inside a scenario outlines in some words.
I have
Scenario outlines : Test John access
Given John enters
When He could access to <area>
Then the access is <result>
Examples:
| area | result |
| parking | authorized |
| security | refused |
I don't want to do copy this test for each employees.
I want to loop this like :
Scenario outlines : Test user autorization
Given all my employees :
| name |
| John |
| Jack |
| Lisa |
Scenario outlines : Test user access
Given <employee> enters
When He could access to <area>
Then the access is <result>
Examples:
| area | result |
| parking | authorized |
| security | refused |
How i could do it ?
Thanks in advance for your ideas.

The simplest answer would be to also add the employee to the Examples table. You wouldn't have to copy the test, but you would still have to multiply the number of rows if you want to test all areas for each employee:
Examples:
| employee | area | result |
| John | parking | authorized |
| John | security | refused |
| Jack | parking | authorized |
| Jack | security | refused |
| Lisa | parking | authorized |
| Lisa | security | refused |
This, however, also allows you to test different privilege levels per user.

Related

Reducing amount of http requests by grouping queries

So I have a bunch of chatty http requests in my Angular 1 app which are bottle necking many of the other requests.
Imagine I have a list of Users from a totally different data source and I make calls to 5 different tables such as:
user.signup
+-----+------------+
| uid | date |
+-----+------------+
| 1 | 2016-12-13 |
| 2 | 2016-12-01 |
+-----+------------+
user.favourite_color
+-----+-------+
| uid | color |
+-----+-------+
| 1 | red |
| 5 | blue |
| 7 | green |
+-----+-------+
user.location
+-----+-----------+
| uid | location |
+-----+-----------+
| 2 | uk |
| 3 | france |
| 9 | greenland |
+-----+-----------+
The reason they are in different tables are because the fields are optional.
The way I see it I have 3 options:
Put them in 1 table
So I could just group them all in 1 table and have a bunch of null columns but that just doesn't sit right with me in terms of DB design.
+-----+------------+-----------+-------+
| uid | date | location | color |
+-----+------------+-----------+-------+
| 1 | 2016-12-13 | null | red |
| 2 | 2016-12-01 | uk | null |
| 3 | null | greenland | null |
| 5 | null | null | blue |
+-----+------------+-----------+-------+
Join them all with 1 request
So I could just have one query that joins all these tables but the way I see it they would have to be full joins with the expectation that some uid's wouldn't exist in some tables. e.g.
+------+------------+-------+-----------+-------+-------+
| uid | date | l_uid | location | c_uid | color |
+------+------------+-------+-----------+-------+-------+
| 1 | 2016-12-13 | null | null | 1 | red |
| 2 | 2016-12-01 | 2 | uk | null | null |
| null | null | 3 | greenland | null | null |
| null | nul | null | null | 5 | blue |
+------+------------+-------+-----------+-------+-------+
which is probably even worse!
Change the way the requests are made?
Maybe make some clever changes how the requests are made:
function activate() {
$q.all([requestSignupDate(), requestFaveColor(), requestLocation(), ....])
.then(function (data) {
//do a bunch of stuff with the data
});
}
which I want to change to:
function activate() {
requestUserData();
}
Any suggestions?
This is a typical ORM problem - precisely this database does not provide a better way of storing the user as an entity.
The entity properties are spread out in multiple tables and due to being optional you are taxed to do left joins with multiple tables.
So you have to essentially solve that problem first. You have several options or (non-options without knowing requirements.)
Put them in one table
If you can use nullable columns and refactor your application - this is preferable. I see that your other tables have just one or two more fields. Heavily normalized tables saves some space and with no data repetition other normalization benefits are moot.
Join them all with 1 request
Only if your query stays performant. Can you use left join ?
You would do this if the above option is difficult. Use this only as a quick fix.
Other options To solve Database Problem
Use server side caching if feasible.
If feasible use a different NoSQL database (e.g. MongoDB)
Change the way the requests are made?
Do you really need all the properties upfront ? The web is asynchronous so why not keep things async. Use $q.all only if you need all the properties. For example the user may not even navigate/scroll to certain part of the page to see stuff so why may queries in the first place.
Along with this you can cluster your server side and the database so that these queries fall on multiple machines and load gets distributed. You may get some items retrieved in parallel.
If the number of columns are all that you have and the tables are all that you mentioned i.e. the supplemental tables have fewer properties I would go with Put them in 1 table option.
Why doesn't using nullable fields sit right with you? NULL exists because it's useful, and a profile table with optional values for a fixed set of fields is practically the textbook case for invoking it. If fields can be dynamically redefined (eg swapping out "favorite color" for "favorite food"), it's another story, but that's not a requirement in what you've described.

Can I get text to display as the values in a TABLIX

I would like to use a tablix to display text values but I'm at a loss for how to do this
I have a query that produces data like this
PersonGroup | Person | Question | Answer
----------------------------------------
Manager | Bob | lunch | yes
Manager | Bob | break | yes
Supervisor | Tim | lunch | No
Supervisor | Tim | break | No
I would like to use a tablix to break the data out like this
Question | Managers | Supervisors
| Bob | Phil | Tim | Susan
Lunch | yes | yes | No | yes
Break | yes | no | No | no
So person group is a parent grouping to person. I've set up my tablix like this and when there is only 1 person per person group the text values(yes's and no's) are displayed. If there is one person per persongoup however the data is blank.
In order to answer your question I've recreated your scenario using this dataset:
You can achieve the desired tablix using a matrix report item with the following data arrangement.
It should preview the following tablix:
Let me know if this can help you.

Using category attribute of a cfindex tag

I'm trying to index a database table using a <cfindex>. I also want to categorize the index based on the values of a column of the same table. No documentation I have come across clearly mention what the "category" attribute takes. Is it a column name or just any desire value and if the later then how do the index determine which record belongs to what category?
Thanks a lot in Advance.
| ID | CATEGORY | NAME | DETAILS | DATE |
| 1 | people | John | John details | 01/23/1980 |
| 2 | animal | Dog | dogs details | 02/22/1990 |
| 3 | people | Ben | Ben's details | 10/10/2006 |
| 4 | animal | panda | panda's details | 07/17/2009 |
The docs didn't make it clear, but if you are indexing a database and there is a column that you want to use for the category, just pass the name of the db column to the category attribute.

Designing a database for dynamic affiliate links

I am in the planning phase of building a site that depends on affiliate links. I'm having a hard time coming up with a good design because the affiliate links change based on different criteria:
Product ID
Affiliate ID
User's location
User's device
For example:
The link http://site.com/affiliate/11111/id/10000 is for the following criteria:
Product 10's link is clicked
User's country is US, UK, CA or AU
They're using an Android device
For http://site.com/affiliate/11111/id/10001
Product 10's link is clicked
User's country is US, UK, CA or AU
Using iOS device
For http://site.com/affiliate/11111/id/10002
Product 10's link is clicked
User's country is DE
Using Android device
Basically, if any of those factors change, it could have a specific link for it. It's not consistent.
I'm probably going to use mod_rewrite to help focus on the queries to be something like:
http://mysite.com/outgoing/product-name/11111/android/us
This will be used to generate a query, but I don't know what I want to do for the database design so it's flexible and prevents having to manually inserting a link that matches every possible combination.
I was originally thinking of a single table like this:
link_id - Auto_incremented PK
affiliate_id
country_code
product_id
affiliate_link
But to do the first example above for just one single product_id:
| link_id | affiliate_id | country_code | device | product_id | affiliate_link |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 1 | 11111 | US | android | 10 | http://site.com/affiliate/11111/id/10000 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 2 | 11111 | UK | android | 10 | http://site.com/affiliate/11111/id/10000 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 3 | 11111 | CA | android | 10 | http://site.com/affiliate/11111/id/10000 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 4 | 11111 | AU | android | 10 | http://site.com/affiliate/11111/id/10000 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 5 | 11111 | US | iOS | 10 | http://site.com/affiliate/11111/id/10001 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 6 | 11111 | UK | iOS | 10 | http://site.com/affiliate/11111/id/10001 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 7 | 11111 | CA | iOS | 10 | http://site.com/affiliate/11111/id/10001 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 8 | 11111 | AU | iOS | 10 | http://site.com/affiliate/11111/id/10001 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 9 | 11111 | DE | android | 10 | http://site.com/affiliate/11111/id/10002 |
+---------+--------------+--------------+--------------+--------------------------------------------------------+
| 10 | 11111 | DE | iOS | 10 | http://site.com/affiliate/11111/id/10003 |
See why I'm hesitant to do it this way?
It just seems so inefficient and complicated. There has to be a better way to do this, but I just can't think of it right now.
To make it more complicated, sometimes I'll get a link for "any country", but excluding the ones that already have a link.
I'd appreciate any help.
You need two different tables: one table stores the atomic data about each affiliate (id, product code, link) and one for the non-atomic data, the country code; this table would need only two columns which together create the unique, primary key - affiliate id + country code. This solution would prevent the needless repetition of data.

Database design: merge users from different logging systems (google, facebook, openid ...)

Hallo,
I need to merge users from several souces some how, for example facebook, Google, plaxo...
Currently I have this structure in my database:
USERS_MYSITE
mysite_user_id | parameter | value
------------------------------------------
223 | firstname | Tom
223 | lastname | N.
223 | birthdate | 1985-01-30
USERS_FACEBOOK
mysite_user_id | facebook_user_id | parameter | value
-------------------------------------------------------------
223 | 456353453 | fname | Tom
223 | 456353453 | lname | N.
223 | 456353453 | birth | 1985-01-30
USERS_GOOGLE
mysite_user_id | google_user_id | parameter | value
-----------------------------------------------------------
223 | tomtom22 | fn | Tom
223 | tomtom22 | ln | N.
223 | tomtom22 | brt | 1985 JUN 30
USERS_VIEW
mysite_user_id | remote_user_id | site_name | parameter | value
---------------------------------------------------------------------------
223 | 223 | mysite | firstname | Tom
223 | 223 | mysite | lastname | N.
223 | 223 | mysite | birthdate | 1985-01-30
223 | tomtom22 | google | fn | Tom
223 | tomtom22 | google | ln | N.
223 | tomtom22 | google | brt | 1985-01-30
223 | 456353453 | facebook | fname | Tom
223 | 456353453 | facebook | lname | N.
223 | 456353453 | facebook | birth | 1985 JUN 30
Then SELECT FROM USERS_VIEW WHERE mysite_user_id = '223' and i got all user information. After that i can use several transporation arrays, to transform all remote data to my format
Array("firstname" => Array("fn", "fname"), "birthdate" => Array("brt", "birth"), ...)
same goes with values. Next depending on what user selected as his primary data i can show it.
Problem is that I've never done it before, so maybe somebody knows how to do it better. Please share your ideas.
Thank you.
the idea was to create a engine, which could combine many accounts from many different "account holders", with possibility to add new if needed. Plus, give possibility to user customize his account data; to take first name from one source, last name from another and add from profile form. I worried about query speed, cause it's quite risky to make such slow query every time for every user shown on screen. Also we get a big traffic, about 1 million a day, that's 20 million page views, and about 100 000 000 query executions. That's a big count.
Yes, the problem is already solved. I just created another table, with duplicated data :( .
Every time user changes some of his settings a new table take update from structure above. Then we taking data only from that new table, and that method works fine. Already added linked in and twitter to sources list. Currently thinking to export that engine and make it open source. :)
You've probably already solved your problem by now - but in case you still need help, I'm happy to help. This is the kind of problem I like.
But in order to help, can you tell me what final outcome you actually want? You've got a solution that should work and I'm not sure if you're saying that you want it to produce a different outcome or that you want it to produce the current outcome but more efficiently?
If you can clarify that, we can sort this out.

Resources