Permalink
Browse files

fixes test.

removed django==trunk from travis, still in tox
  • Loading branch information...
saxix committed Jan 2, 2014
1 parent 86dab63 commit 2e37ecfdec8e33f0929fbc85c8193a6132294562
View
@@ -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"
@@ -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
@@ -2,27 +2,36 @@
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;
text-align: center;
}
.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;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -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");

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -30,39 +30,39 @@
<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>
{% for field in fields %}
<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 %}
@@ -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();
+
@@ -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();
+
@@ -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
@@ -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
@@ -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

0 comments on commit 2e37ecf

Please sign in to comment.