Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes test.

removed django==trunk from travis, still in tox
  • Loading branch information...
commit 2e37ecfdec8e33f0929fbc85c8193a6132294562 1 parent 86dab63
@saxix authored
View
1  .travis.yml
@@ -9,7 +9,6 @@ env:
- DJANGO="1.4.x" DBENGINE=pg
- DJANGO="1.5.x" DBENGINE=pg
- DJANGO="1.6.x" DBENGINE=pg
- - DJANGO="dev" DBENGINE=pg
install:
- "export PATH=$PWD/~build/casperjs/bin:$PATH"
View
1  adminactions/requirements/testing.pip
@@ -3,6 +3,7 @@ selenium>=2.32.0
django-webtest>=1.7.5
WebTest>=2.0.7
django-dynamic-fixture
+sample-data-utils
coverage
pytest
pytest-django
View
17 adminactions/static/adminactions/css/adminactions.css
@@ -2,6 +2,12 @@
width: 100%;
border: 1px solid black;
}
+p.display {
+ width: 300px;
+ overflow: hidden;
+ white-space: nowrap;
+ /*word-wrap: break-word;*/
+}
.mergetable tr.header th {
font-weight: bold;
@@ -9,20 +15,23 @@
}
.mergetable td {
+ /*width: 30%;*/
vertical-align: middle;
border-right: 1px solid #000000;
}
.mergetable .column {
+ /*width: 30%;*/
}
.mergetable .origin *, .mergetable .result * {
- width: 100px;
- word-wrap: break-word;
+ /*width: 30%;*/
+ /*word-wrap: break-word;*/
+ /*white-space:pre-line;*/
}
.mergetable .label {
- width: 10%;
+ /*width: 10%;*/
font-weight: bold;
}
@@ -35,7 +44,7 @@
}
.mergetable input.raw-value {
- width: 200px;
+ /*width: 200px;*/
border: 0px transparent;
background-color: transparent;
display: none;
View
2  adminactions/static/adminactions/css/adminactions.min.css
@@ -1 +1 @@
-.mergetable{width:100%;border:1px solid black}.mergetable tr.header th{font-weight:bold;text-align:center}.mergetable td{vertical-align:middle;border-right:1px solid #000}.mergetable .origin *,.mergetable .result *{width:100px;word-wrap:break-word}.mergetable .label{width:10%;font-weight:bold}.mergetable .selected{background-color:#81b10c}.mergetable .changed{background-color:#f9adaf}.mergetable input.raw-value{width:200px;border:0 transparent;background-color:transparent;display:none}
+.mergetable{width:100%;border:1px solid black}p.display{width:300px;overflow:hidden;white-space:nowrap}.mergetable tr.header th{font-weight:bold;text-align:center}.mergetable td{vertical-align:middle;border-right:1px solid #000}.mergetable .label{font-weight:bold}.mergetable .selected{background-color:#81b10c}.mergetable .changed{background-color:#f9adaf}.mergetable input.raw-value{border:0 transparent;background-color:transparent;display:none}
View
4 adminactions/static/adminactions/js/merge.js
@@ -22,10 +22,10 @@
if ($('input.raw-value', $result).val() == $('input.raw-value', $left).val()) {
$(this).find('td.origin').addClass("selected");
- $('span.display', $result).text($('span.display', $left).text());
+ $('p.display', $result).text($('p.display', $left).text());
} else if ($('input.raw-value', $result).val() == $('input.raw-value', $right).val()) {
$(this).find('td.other').addClass("selected");
- $('span.display', $result).text($('span.display', $right).text());
+ $('p.display', $result).text($('p.display', $right).text());
RIGHT.push(field_name);
}else if ($('.original .display', this).text() !== $('.result .display', this).text()){
$(this).addClass("changed");
View
2  adminactions/static/adminactions/js/merge.min.js
@@ -1 +1 @@
-(function(a){a(function(){var b=function(d){return function(){var e=a(this).parent().parent();var f=e.find(d);a(".result input",e).val(a("input.raw-value",f).val());c()}};var c=function(){var d=[];a(".mergetable tr.merge-row").each(function(){var f=a(this).find("td.result");var g=a(this).find("td.origin");var e=a(this).find("td.other");var h=a(this).find("td:first").attr("data-content");a("td",this).removeClass("selected");if(a("input.raw-value",f).val()==a("input.raw-value",g).val()){a(this).find("td.origin").addClass("selected");a("span.display",f).text(a("span.display",g).text())}else{if(a("input.raw-value",f).val()==a("input.raw-value",e).val()){a(this).find("td.other").addClass("selected");a("span.display",f).text(a("span.display",e).text());d.push(h)}else{if(a(".original .display",this).text()!==a(".result .display",this).text()){a(this).addClass("changed")}}}});a("input[name=field_names]").val(d)};a("a.origin").click(b("td.origin"));a("a.other").click(b("td.other"));a("a.swap").click(function(){var f=[];var d=[];var g=a('input[name="master_pk"]');var e=a('input[name="other_pk"]');a(".column.origin").each(function(){f.push([a("input.raw-value",this).val(),a(".display",this).text()])});a(".column.other").each(function(){d.push([a("input.raw-value",this).val(),a(".display",this).text()])});f.push(g.val());d.push(e.val());g.val(d.pop());e.val(f.pop());a('span[id="master_pk"]').text(g.val());a('span[id="other_pk"]').text(e.val());a(a(".column.origin").get().reverse()).each(function(){var h=d.pop();a("input.raw-value",this).val(h[0]);a(".display",this).text(h[1])});a(a(".column.other").get().reverse()).each(function(){var h=f.pop();a("input.raw-value",this).val(h[0]);a(".display",this).text(h[1])});c()});c()})})(django.jQuery);
+(function(a){a(function(){var b=function(d){return function(){var e=a(this).parent().parent();var f=e.find(d);a(".result input",e).val(a("input.raw-value",f).val());c()}};var c=function(){var d=[];a(".mergetable tr.merge-row").each(function(){var f=a(this).find("td.result");var g=a(this).find("td.origin");var e=a(this).find("td.other");var h=a(this).find("td:first").attr("data-content");a("td",this).removeClass("selected");if(a("input.raw-value",f).val()==a("input.raw-value",g).val()){a(this).find("td.origin").addClass("selected");a("p.display",f).text(a("p.display",g).text())}else{if(a("input.raw-value",f).val()==a("input.raw-value",e).val()){a(this).find("td.other").addClass("selected");a("p.display",f).text(a("p.display",e).text());d.push(h)}else{if(a(".original .display",this).text()!==a(".result .display",this).text()){a(this).addClass("changed")}}}});a("input[name=field_names]").val(d)};a("a.origin").click(b("td.origin"));a("a.other").click(b("td.other"));a("a.swap").click(function(){var f=[];var d=[];var g=a('input[name="master_pk"]');var e=a('input[name="other_pk"]');a(".column.origin").each(function(){f.push([a("input.raw-value",this).val(),a(".display",this).text()])});a(".column.other").each(function(){d.push([a("input.raw-value",this).val(),a(".display",this).text()])});f.push(g.val());d.push(e.val());g.val(d.pop());e.val(f.pop());a('span[id="master_pk"]').text(g.val());a('span[id="other_pk"]').text(e.val());a(a(".column.origin").get().reverse()).each(function(){var h=d.pop();a("input.raw-value",this).val(h[0]);a(".display",this).text(h[1])});a(a(".column.other").get().reverse()).each(function(){var h=f.pop();a("input.raw-value",this).val(h[0]);a(".display",this).text(h[1])});c()});c()})})(django.jQuery);
View
26 adminactions/templates/adminactions/merge.html
@@ -30,15 +30,15 @@
<td>{{ adminform.form.dependencies }}</td>
</tr>
</table>
- <table class="mergetable">
+ <table class="mergetable" style="width:100%; overflow: hidden">
<tr class="header">
<th>{% trans "Field" %}</th>
- <th>{% trans "Master" %} #<span id='master_pk'>{{ master.pk }}</span> ({% trans "This will be preserved" %})
+ <th class="master">{% trans "Master" %} #<span id='master_pk'>{{ master.pk }}</span> ({% trans "This will be preserved" %})
</th>
- <th><a class="swap" href="#">{% trans "swap" %}</a></th>
- <th>{% trans "Result" %}</th>
+ <th><a class="swap" id="swap_cols" href="#">{% trans "swap" %}</a></th>
+ <th class="result">{% trans "Result" %}</th>
<th></th>
- <th>{% trans "Other" %} #<span id='other_pk'>{{ other.pk }}</span> ({% trans "This will be removed" %})
+ <th class="other">{% trans "Other" %} #<span id='other_pk'>{{ other.pk }}</span> ({% trans "This will be removed" %})
{# {{ adminform.form.other_pk.value }}#}
</th>
</tr>
@@ -46,23 +46,23 @@
<tr class="{% cycle "row1" "row2" %} merge-row">
<td class="column label" data-content="{{ field.name }}">{{ master|verbose_name:field.name }}</td>
- <td class="column origin">
+ <td class="column origin master_{{ field.name }}">
{{ formset.0|widget:field.name }}
- <span class="display">{{ master|field_display:field}}</span>
+ <p class="display">{{ master|field_display:field}}</p>
</td>
- <td><a class="origin" href="#"> &gt;&gt; </a></td>
+ <td><a class="origin" id="master_{{ field.name }}" href="#"> &gt;&gt; </a></td>
- <td class="column result">
+ <td class="column result result_{{ field.name }}">
{{ adminform.form|widget:field.name }}
- <span class="display"></span>
+ <p class="display" id="result_{{field.name}}"></p>
{{ adminform.form|errors:field.name }}
</td>
- <td><a class="other" href="#"> &lt;&lt; </a></td>
+ <td><a class="other" id="other_{{ field.name }}" href="#"> &lt;&lt; </a></td>
- <td class="column other">
+ <td class="column other other_{{ field.name }}">
{{ formset.1|widget:field.name }}
- <span class="display">{{ other|field_display:field }}</span>
+ <p class="display">{{ other|field_display:field }}</p>
</td>
</tr>
{% endfor %}
View
63 tests/functional/casper-tests/merge.js
@@ -0,0 +1,63 @@
+/**
+ *
+ * User: sax
+ * Date: 12/27/13
+ * Time: 8:02 PM
+ *
+ */
+
+casper.test.comment('Casper merge test');
+var helper = require('./djangocasper.js'),
+ utils = require('utils'),
+ http = require('http'),
+ tools = require('./tools.js'),
+ fs = require('fs');
+
+
+helper.scenario(
+ casper.cli.options['url'],
+ function (response) {
+ /*
+ select records in changelist
+ */
+ tools.assertStatusCode(response);
+ casper.test.assertTextExists('Select user to change');
+ tools.selectElements(casper.cli.options['ids']);
+ this.fill('#changelist-form', {action: 'merge'}, false);
+ this.click('button[name="index"]');
+ this.waitForSelector("#id_last_name",
+ null,
+ function () {
+ casper.capture("pageError.png");
+ });
+ },
+ function (response) {
+ /* merge */
+ tools.assertStatusCode(response);
+ casper.test.assertTextExists('Master #' + casper.cli.options['master_id']);
+ this.click('#other_last_name');
+ this.click('#other_first_name');
+ this.waitForSelector("td.column,other,selected");
+ casper.capture("AAAAAAA.png");
+ this.click('input[name=preview]');
+ this.waitForSelector("table.mergetable",
+ null,
+ function () {
+ casper.capture("pageError.png");
+ });
+ },
+ function (response) {
+ /* preview */
+ casper.test.assertTextExists('After Merging');
+ casper.capture("page.png");
+ this.click('input[name=apply]');
+ this.waitForSelector("#changelist-form");
+ },
+ function (response) {
+ this.test.assert(true);
+ }
+);
+
+
+helper.run();
+
View
77 tests/functional/casper-tests/merge_swap.js
@@ -0,0 +1,77 @@
+/**
+ *
+ * User: sax
+ * Date: 12/27/13
+ * Time: 8:02 PM
+ *
+ */
+
+casper.test.comment('Casper merge test');
+var helper = require('./djangocasper.js'),
+ utils = require('utils'),
+ http = require('http'),
+ tools = require('./tools.js'),
+ fs = require('fs');
+
+
+helper.scenario(
+ casper.cli.options['url'],
+
+ function (response) {
+ /*
+ select records in changelist
+ */
+ tools.assertStatusCode(response);
+ casper.test.assertTextExists('Select user to change');
+ tools.selectElements(casper.cli.options['ids']);
+ this.fill('#changelist-form', {action: 'merge'}, false);
+ this.click('button[name="index"]');
+ this.waitForSelector("#id_last_name",
+ null,
+ function () {
+ casper.capture("pageError.png");
+ });
+ },
+ function (response) {
+ tools.assertStatusCode(response);
+ casper.test.assertTextExists('Master #' + casper.cli.options['master_id']);
+ this.click('#swap_cols');
+ this.waitForText("Master #" + casper.cli.options['other_id'], null,
+ function () {
+ casper.capture("pageError.png");
+ });
+ },
+ function (response) {
+ /*
+ merge
+ */
+ this.click('#master_username');
+ this.click('#other_last_name');
+ this.click('#other_first_name');
+
+ this.waitForSelector("td.column,other,selected");
+
+
+ this.click('input[name=preview]');
+ this.waitForSelector("table.mergetable",
+ null,
+ function () {
+ casper.capture("pageError.png");
+ });
+ },
+ function (response) {
+ /*
+ preview
+ */
+ casper.test.assertTextExists('After Merging');
+ this.click('input[name=apply]');
+ this.waitForSelector("#changelist-form");
+ },
+ function (response) {
+ this.test.assert(true);
+ }
+);
+
+
+helper.run();
+
View
66 tests/functional/test_merge.py
@@ -0,0 +1,66 @@
+import os.path
+from functools import partial
+from casper.tests import CasperTestCase
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
+from django.test import Client
+from django_dynamic_fixture import G
+from sample_data_utils.utils import sequence
+from django_webtest import WebTestMixin
+import pytest
+
+list_to_string = lambda q: ','.join(map(str, q))
+
+
+@pytest.mark.functional
+class MergeTest(WebTestMixin, CasperTestCase):
+ def setUp(self):
+ names = partial(sequence, 'username', cache={})()
+ first_names = partial(sequence, 'First', cache={})()
+ last_names = partial(sequence, 'Last', cache={})()
+
+ self.client = Client()
+ self.user = User.objects.create_superuser('sax', '', '123')
+ self.client.login(username=self.user.username, password='123')
+ G(User, n=5, username=lambda x: next(names),
+ first_name=lambda x: next(first_names),
+ last_name=lambda x: next(last_names))
+
+ def test_success(self):
+ master = User.objects.get(username='username-0')
+ other = User.objects.get(username='username-1')
+ ids = list_to_string([master.pk, other.pk])
+
+ url = reverse('admin:auth_user_changelist')
+ test_file = os.path.join(os.path.dirname(__file__), 'casper-tests/merge.js')
+ self.assertTrue(self.casper(test_file,
+ url=url,
+ ids=ids,
+ master_id=master.pk,
+ other_id=other.pk,
+ engine='phantomjs'))
+
+ result = User.objects.get(id=master.pk)
+ assert result.username == master.username
+ assert result.last_name == other.last_name
+ assert result.first_name == other.first_name
+ assert not User.objects.filter(pk=other.pk).exists()
+
+
+ # def test_swap(self):
+ # master = User.objects.get(username='username-0')
+ # other = User.objects.get(username='username-1')
+ # ids = list_to_string([master.pk, other.pk])
+ #
+ # url = reverse('admin:auth_user_changelist')
+ # test_file = os.path.join(os.path.dirname(__file__), 'casper-tests/merge_swap.js')
+ # self.assertTrue(self.casper(test_file,
+ # url=url,
+ # ids=ids,
+ # engine='phantomjs'))
+ #
+ # result = User.objects.get(id=other.pk)
+ # assert result.username == other.username
+ # assert result.last_name == master.last_name
+ # assert result.first_name == master.first_name
+ # assert not User.objects.filter(pk=master.pk).exists()
View
2  tests/settings.py
@@ -63,7 +63,7 @@
USE_TZ = True
MEDIA_ROOT = os.path.join(here, 'media')
MEDIA_URL = ''
-STATIC_ROOT = ''
+STATIC_ROOT = os.path.join(here, 'static')
STATIC_URL = '/static/'
SECRET_KEY = 'c73*n!y=)tziu^2)y*@5i2^)$8z$tx#b9*_r3i6o1ohxo%*2^a'
MIDDLEWARE_CLASSES = (
View
5 tox.ini
@@ -45,3 +45,8 @@ setenv =
basepython = python3.2
setenv =
DJANGO=1.6.x
+
+[testenv:local-dev]
+basepython = python2.7
+deps =
+ git+git://github.com/django/django.git
Please sign in to comment.
Something went wrong with that request. Please try again.