How to execute a scenario from another scenario? - python-behave

Below is the example where I want to execute a scenario in another scenario. Is there any way to do this?
Scenario: scenario-A
Create an object obj-A
Read 'key1' from the object obj-A
Scenario: scenario-B
Step1: Create an object obj-B
Step2: Read 'key2' from obj-B
Step3: # I want to execute scenario-A here. This gives me value of 'key-1'
Step4: Perform an operation using 'key1' and 'key2'

Use context.execute_steps() to rebuild your scenario or part of it from inside another step. I think it's worthwhile to keep your second scenario more streamlined and focused on whatever it is that you're testing, but be careful with future maintenance.

Related

Integration Segment with Salesforce, adding an action

All I want to do is,
Add Salesforce as destination
From the Track Object, get a field
Update to Salesforce
I created a custom action
But it does not work
everytime it inserts a lead
My action is not executed
What am I doing incorrect?
Below image I am testing to create a case to see if that works.
It throws and error for not including Salesforce:true.
Not sure where to include that
I think the issue is that you are using the Create operation for the action. Instead of creating a new case, you should use an Update operation. As the form says:
If the CRUD Operation is Update an ID field mapping is required.
I can't see that you have included an ID field in your field mappings there either. You will need that ID, so that you can update your customer.

How to make Laravel use my class instead of native PDO?

I'm facing a big problem here. I work using laravel 5.1 and Sql Server 2012. The problem is:
All tables of my database have a trigger that is responsible to log activities on that table. This trigger do a insert after the insert on the main table. This way, every time I insert a new Person, the trigger will insert a new PersonLog.
This way, on Laravel when I do:
$person = Person::create(['personName' => 'Anderson']);
echo $person->id; //it tries to show me the log id instead of person id.
It happens because PDO uses ##identity variable to search for the last inserted id instead of use SCOPE_IDENTITY().
Solutions:
- I tried a pull request on laravel source using a manual query instead of pdo lastInsertId() method. It was denied.
- The another solution is create a class extending PDO and make laravel use my class instead of native pdo. But I don't have any idea of how to do it.
Can you guys help me?
Thank you!
I solved it!
It was really easy by the way, and I can't imagine how I didn't think on it. What did I do? Let me explain:
First, I created a child from SqlServerGrammar inside my project
In my SqlServerGrammar I override the compileInsert method
In my AppServiceProvider on the boot method, I changed the grammar my connection use, this way: \DB::connection()->setQueryGramar(app(App\Classes\MyCustom\SqlServerGrammar::class));

best way to add categories to database

I'm looking for the best/most efficient way to add categories that save to a database. I've created the category model with a name column. I generated the controller. My first thought was to just enter the categories directly into the controller since I will be the only one that can create, edit, and destroy them. This is what it looked like:
class CategoriesController < ApplicationController
def women
end
def kids
end
def babies
end
def home_decor
end
end
Fine, but that doesn't save to the db and since I'd like to associate these categories w/ products later I need it to save to the db. I could create these categories directly in console, but I'm not sure if when I push to production (on Heroku) how to create them again (and that seems a little tedious).
The other option I have is to create a form to create the categories and only give access to an admin.
Am I missing something? Is there a more efficient way to do this or is the admin route the best way to handle it?
Thanks for any suggestions!
Forget that controller. What you are looking for is in db/seeds.rb. It's just a script where you place the default content of your database. So in your case you'll need to put the following:
Category.delete_all # For avoiding duplicate content
Category.create!({id: 1, name: 'women'}) # Use create! so you'll know if there is any errors
Category.create!({id: 2, name: 'kids'})
# etc...
Then just run the script for placing that content in the db:
rake db:seed
And in heroku:
heroku run rake db:seed

How to Create a CaseFeed Under a Case?

I am trying to display case with CaseFeeds and FeedComments on my console app support page. Now when users reply to a case I want to insert a CaseFeed from my application. As per the salesforce API docs, create or upsert is not supported on CaseFeed.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_casefeed.htm
Is there any way or work around to create a CaseFeed under Case?
CaseFeed it like a view - a combination of all kinds of activities happening to the Case.
It's bit similar to how Events and Tasks can be viewed together on a related list of Open Activities. Check the Type field to see what does it aggregate. It kind of makes sense for a view to be readonly.
You can imitate user posting to that Case instead - that'd be FeedItem object.
insert new FeedItem(
ParentId = '50070000006Rn5M',
Title='Some title',
Body = 'Some long text goes here',
Type='TextPost'
);

How to creating ACOs?

I think I have undestood the bases of almost everything in CakePHP until the Access Control Lists, now I'm on 11.2.5 Creating ACOs (Access Control Objects) and I don't understand where I have to put the AclComponent methods:
$this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'controllers'));
$this->Acl->Aco->save();
In which file I should insert this code?
Have I to inserti in some specific statement?
I don't undestand what this line does exactly, so I can't locate where and when it should run, what this code does, and when It should work?
The idea with the ACO records creation is that if your project is over (meaning no new actions are created), you don't need to insert anything anymore in the acos datatable. These methods are intended to be called once, or only a few times.
It is then up to you to decide where you want to place these lines of code, as anyway you will probably remove them afterwards.
Alternatively, to fill the acos datatable, you could also use this plugin http://www.alaxos.net/blaxos/pages/view/plugin_acl that automatically detects new actions and propose to complete the acos datatable accordingly.
you can insert that wherever you need to create Aco-s. in app_controller, or in any controller.
This page in the Cookbook gives you a very nice automated tool for creating ACOs:
http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
If you add the build_acl function to the AppController, you can run it from any controller and it generates your ACOs for you. It's always worked very nicely in my ACL-using applications.

Resources