Django Testing - Error: object has no attribute 'assertHTML' - django-testing

I have a form with name and email, want to test it.
I am trying to test the HTML content after the post, some thing as below.
I simulated the post data as follows.
response = self.c.post('/app/url/', {'name': 'xxx', 'email': 'xxx#gmail.com')
After the user post the data, I want to verify the name and email from the HTML content as follows.
with self.assertHTML(response, 'input[name="xxx"]') as (elem,):
self.assertEqual(elem.value, 'xxx')
While run the tests I am getting the error:
object has no attribute 'assertHTML'
Can any one provide suggestions how to resolve this error, if any package needs to be installed please suggest what to install and how to install.

In the django docs I can neither find assertHTML as method nor does a context manager like this exist.
The docs you are refering to are for an additional package https://pypi.python.org/pypi/django-with-asserts. If you want to use it, you need to install it and import it. Have you done that?
If you had give the full code, it would have been much easier and people would not need to guess, what you have imported.

Related

Branch.io api update type. Make previously created link appear on quick links

I created a bunch of links through the API without specifying the type which defaults to 0. This doesn't make the links show on the dashboard under quick links. Now, I would like to make them show there but there doesn't seem to be an option to add a quick link, only create new. Given this, my idea was to use the API to read and update it however, update doesn't seem to allow passing argument type. Any hints on how to overcome this?
I have made a get request, retrieving the whole link details, copied the result, added the branch_key and branch_secret, changed type from 0 to 2 and sent an update request.
I've opened the link with ?debug=true but it doesn't seem to be a way to edit it to make it show on quick links either.
Response code was:
{
"error": {
"code": 400,
"message": "Invalid parameter: type"
}
}
As soon as I remove the type parameter, I get the proper link response with all the data.
The error that you saw is the expected behavior. The "type" key is reserved key and is not able to be changed once you created the link. You can manually set this only when you create the link using the API call. Please do reach out at integrations#branch.io if you have any further questions!
We store API created links and quick links in different DBs due to the volume of each type. This means that it's actually impossible to create a quick link through our public API or SDK. The only place would be from the dashboard. :( Hopefully, you understand our reasoning for doing it this way.

Can't upload new product image backend prestashop

I need a little help here, i hope someone here can help me for a hint or clue.
First of all, I'm not programmer. I'm just web admin who can use cms and basic html.
I was using PrestaShop for my online shop. In the backend, I can't upload new product image anymore.
The error just blank without any sign for me. Here for the screenshot:
I appreciate it, if someone can help me, thanks, and sorry for my english.
#PanjiWiyono This errors don't really give us a quality information, but this is a start. In your JS code should be a ajax query that has an error when converting results to json (first error). You should check what's the exact error that this request is returning by inspecting in browser developer console.
If you detect that the second error is in fact, the response of this ajax query, well now we almost have the problem.
The second error should be related to data size. Check this: Error while sending QUERY packet
Anyway, you should check DbPDO.php class. You can use debug_backtrace function to display the complete stack, but definitly if error is related to a basic PHP class issue you will have not help knowing wich classes are in calling stack.
Good luck.
Simple solution
maybe a extra module is in a conflict with the prestashop core files. go to advanced parameters, performance and disable third party modules and try again.
other option is reupload admin folder with other name and
js folder check again
hope it will work for you

How can I retrieve a Gitlab Project tag list through the API?

I'm writing a REST client to look at project information available from several gitlab servers at the same time in one consolidated place. I understand REST and am able to pull the project details I need except one: the tags.
I'm not talking about git repository tags, those I'm able to get to just fine. I'm referring to the tags that are set under Project Settings. These are tags that, from what i can tell, are meant to be a form of describing the project, not referencing a particular commit hash.
I submitted a merge request back to the Gitlab folks, if accept, any REST call that involves a Project class will include a "tag_list" field with all the project labels.
The merge request is available here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/329
EDIT: This was merged in Gitlab version 7.10.0 so now you can just run a GET on the Project and the tag_list will be included with the JSON response.
Try this:
http://www.example.com.br/api/v3/projects/#{str}/repository/tags?private_token=yourtoken"
Note that in #{str} variable, if you using a group/repository structure, you must replace the dash to %2F, for example, you must set:
http://www.example.com.br/api/v3/projects/group%2Frepository/repository/tags?private_token=yourtoken"
The response to your request will be the body. So you can console log response.body to retrieve the tags.
Not possible: ACCEPTING MERGE REQUEST at: http://feedback.gitlab.com/forums/176466-general/suggestions/6325819-project-labels-via-api , so feel free to implement it if you need it.
Should be simple: just return the project.tag_list (see: https://github.com/mbleigh/acts-as-taggable-on) as a JSON list from https://github.com/gitlabhq/gitlabhq/blob/41518a467dcef61deca24ad2f6205c6fd5706e1b/lib/api/projects.rb#L60
Always check the request tracker first for features ;) True, in this case you may have done it an not found because of label vs tag keyword confusion, I think it was renamed at some point, so always search for both.

How do I halt item posting on data validation error in plugin

Let's say I have a plugin Foo in osclass. In that plugin we register a hook for when an item is posted. According to the osclass hooks documentation the only hook that is run when an item is posted is posted_item.
But as far as I can tell from looking at the code this is run after the initial item data has already been validated and stored in the database. What if a validation of some plugin specific code fails and I would like to show the user an error message and present him with the form again to give him/her the chance to alter this information? Much like if you try to submit a new item but don't fill in one of the base information like description for instance.
I can't seem to find a way to do this. Only workaround I find to avoid the item being posted despite containing invalid plugin specific data, without editing the main osclass code, is to delete the posted item again in the posted_item hook callback function of my plugin. This feels extremely cumbersome and also requires every other plugin to check that the item still exists to make sure they don't save data connected to an item that is now deleted.
What I would like, and wonder if I have missed, is a hook that is run when an item is posted but before it's written to the database and have the ability to generate "errors" that would cause the item to not be posted and the user redirected back to the form with the "error" displayed just like for the basic item information.
Anyone have a solution I have missed? This feels like a very important part of plugins and without it posted items could become very fragmented.
A user on the osclass forums (teseo) told me about the undocumented hook pre_item_add that can be used.
<?php
function cust_my_plugin($aItem) {
osc_add_flash_error_message('My plugin has a complaint.');
$pItem = new CWebItem();
$pItem->redirectTo( osc_item_post_url() );
}
osc_add_hook('pre_item_add', 'cust_my_plugin');
?>
He also sais
The only bad news is that you can't merge your plugin validation
process with that of the core script, so if the ad had an error
related to your plugin and other errors, it would be rejected twice,
one by your plugin, the second by the core script. I couldn't see any
workaround for this little issue.

i18n testing using selenium

Have any one used selenium for testing i18n !
Does Selenium provide any kind of I18N/L10N support? Is it possible
to verify text based on message keys from a resource file? What
about checking numbers and dates that might have a different format
because of L10N?
I am also interested in the correct approach for this issue. Where I work, we usually use the ids to verify certain page or field. But, sometimes you might need to verify some text, which could be using i18n.
Try the following:
If you have a selenium-testing module, have the module where the bundle is placed as a dependency. And then define a ReloadableResourceBundleMessageSource in the xml. And than setup the test following this code: https://stackoverflow.com/a/6251478/521754
Hope that helps!
Cheers!