origen_testers ATP flow loop method use case? - origen-sdk

What is the use case for the origen_testers ATP flow 'loop' method? Is this meant to be something users call in their flow file or is something under the hood? Does this method specifically generate something specific for the V93K SMT7 platform?
thx

Something that the users call in their flow file.
I haven't used it personally, but from these spec tests, it looks like you would do something like:
loop from: 0, to: 5, step: 1, var: "vol" do
test :test_loop1
end
The var value is optional, in that case it will presumably generate a variable name.
Being part of the flow, this API can be called for any tester, however I suspect that only the V93K generator actually will actuall do something with it currently.

Related

How to use schedule?

I've seen quite a few examples of 'schedule' being used like this:
Timer().schedule(1000) {
// code to execute after delay
}
However, when I try to use it like this the function needs me to supply some sort of 'TimerTask' and I haven't seen anything about that.
So my question is how do you properly use schedule?

NestJS: Controller function with #UploadedFile or String as a parameter

I am using NestJS (version 6.5, with Express platform) and I need to handle a request with a property that can either be a File or a String.
Here is the code I currently have, but I don't find a clean way to implement this.
MyAwesomeController
#Post()
#UseInterceptors(FileInterceptor('source'))
async handle(#UploadedFile() source, #Body() myDto: MyDto): Promise<any> {
//do things...
}
Am I missing something obvious or am I supposed to write my own interceptor to handle this case?
Design-wise, is this bad?
Based on the fact you're designing a REST API:
It depends what use case(s) you want to achieve: is your - client-side - flow designed to be performed in 2 steps o not ?
Can string and file params be both passed at the same time or is there only one of the two on each call ? (like if you want to update a file and its name, or some other non Multer related attributes).
When you pass a string as parameter to your endpoint call, is a file resource created / updated / deleted ? Or maybe not at all ?
Depending on the answer and the flow that you thought of, you should split both cases handling within two independent endpoints, or maybe it makes sense to handle both parameters at the same time.
If only one of the params can be passed at a time, I'd say go for two independent endpoints; you'll benefit from both maintenance and code readability.
If both params can be passed at the same time and they're related to the same resource, then it could make sense to handle both of them at once.
Hope this helps, don't hesitate to comment ;)

How to use abort method with flask?

I would like to write the second code but I'm not sure of the merit of the first code. Would anyone please tell me the advantage of the first code? Also, can I write the code like the second one instead of the first one?
The first sample that I'm not sure of the advantages and I avoid writing this way:
if not users:
abort(401, {"error_message": "user_id is not defined."})
return user_id, custmer_id
The second sample I would like to use
if not users:
return jsonify({"error_message": "user_id is not defined."}), 401

Cucumber -Given precondition

Hello everyone,
To proceed with order product scenario I should log in, I am asking if I could use in my scenario a given step like :
Scenario: Order product
Given I log in
.
.
And in the steps defintion class I will call the login steps inside the given of order product:
#Given("^I log in$")
public void I_log_in(){
Given(string.Format("I am on login page"));
When(string.Format("I log in with valid username and password));
Then (string.Format("I should be logged in));
}
PS: I tried to use the hook before to run login actions before this scenario using a tag (above it), but I find it's not a good practice to set actions on before, also the Backgound keyword will not work here beacause there are scenarios in the same feature don't require login.
Thanks in advance
I don't think you can do this and you definitely don't want to do this.
If we look at each step you want to nest and think about the code inside it we have
Note: I don't cuke in java but I'll try and explain using your code
Given(string.Format("I am on login page"))
foo code
...
When(string.Format("I log in with valid username and password));
bar code
...
note: the ellipsis represent all the code that does stuff
Now if you want to implement I am on login page and I log in with valid username and password then you can just do
Given(string.Format("I am on login page and I log in with valid username and password")
foo code
...
bar code
...
Now the only problem you have is that you have two copies of foo code. You can solve that by extracting a method. This would give you
Given(string.Format("I am on login page and I log in with valid username and password")
call foo code
call bar code
and would mean that you rewrite your original steps as
Given(string.Format("I am on login page"))
call foo code
When(string.Format("I log in with valid username and password));
call bar code
If you write all your step definitions as single line calls, then you can easily make compound step definitions by just combining calls.
Finally you should make your compound step definition a single call
Given(string.Format("I am on login page and I log in with valid username and password")
call baz code
and then implement baz as
void baz() {
foo
bar
}
So now even your compound call is defined outside of your step definitions.
To do this you have to understand Cucumbers mechanism for allowing you to define and call methods outside of step definitions. This is really easy in Ruby, but I don't know the java equivalent, apologies.
Eventually you'll end up with a number of methods foo, bar, baz that you have to organise. Thats a known simple problem which all programming languages support. By taking this problem out of Cucumber and into Java you will (in the longer term) make things much simpler for yourself.
I hope you can use the ideas here to make you Cuking simpler.
Since it's a precondition, I'd rewrite to Given I am logged in (or maybe even provide some information about what type of user logs in, rather than use I? like a customer, admin, ...?)
Note that you cannot call steps from steps in cucumber-jvm (by design!)
Inside your login() method, you can call several helper methods that perform the actions needed to actually be logged in, like:
navigateToLoginPage();
enterUsernamePassword("user", "pass);
assert.something() // Make sure login was successful
Also, log a message when login was not successful; which will help you analyse failures)

Does origen support 93k multi_bin feature?

The examples for generating tests in the testflow create stop_bins. However there were no examples of how to generate the 93k multi_bin node. Does this feature exist in the current origen-sdk?
output node looks like this in 93k .tf file
if #FLAG then
{
multi_bin;
}
else
{
}
There is currently no direct support for creating multi_bin nodes, though in time I do expect that it will be added as a result of this effort to add support for limits tables.
In the meantime though, there is the ability to render any text and this can be used to generate what you want.
To generate the above example you could do:
if_flag :flag do
render 'multi_bin;'
end
This will also work with in-line conditions, this is the same:
render 'multi_bin;', if_flag: :flag
Additionally, on_pass and on_fail will accept a render option:
func :my_test, on_fail: { render: 'multi_bin;' }
Obviously that is creating something that will not be able to translate to other tester platforms, so the advice is to use render sparingly and only as a get out of jail card when you really need it.
Also note that for these examples to work you need at least OrigenTesters 0.11.1.

Resources