Closed Bug 519916 Opened 15 years ago Closed 15 years ago

Can't run any unit tests

Categories

(Webtools :: ISPDB Server, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: LouieDinh, Assigned: LouieDinh)

References

Details

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/8.10 (intrepid) Firefox/3.0.14
Build Identifier: 

There is no installed unit testing framework installed!

Reproducible: Always

Steps to Reproduce:
1.Run python manage.py test
Actual Results:  
0 unit tests will be run.

Expected Results:  
We should have some unit tests.
Attachment #403979 - Flags: review?(bwinton)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 403979 [details] [diff] [review]
Patch that installs nose and provides a sample unit test

>Index: nose_runner.py
>+"""
>+Django test runner that invokes nose.
>+
>+Usage:
>+    ./manage.py test DJANGO_ARGS -- NOSE_ARGS
>+
>+The 'test' argument, and any other args before '--', will not be passed
>+to nose, allowing django args and nose args to coexist.
>+
>+You can use
>+
>+    NOSE_ARGS = ['list', 'of', 'args']
>+
>+in settings.py for arguments that you always want passed to nose.
>+"""

Did this file come from somewhere else, or did you write it yourself?
If it came from somewhere else, what license is it under?
If you wrote it yourself, please add a licence block to the top of the
file.  (You can find example licenses at: http://www.mozilla.org/MPL/boilerplate-1.1/)


>Index: settings.py
>+#Fixtures
>+FIXTURE_DIRS = (
>+   os.path.join(os.path.abspath("./"),"fixtures/"), #TODO: Clean this up after eric's patch for local settings
>+)

Please make your lines contain less than 80 characters.
One way to do this would be to move the comment to the line above.

>Index: tests/test_xml.py
>+# -*- coding: latin-1 -*-

I really prefer utf-8 coding, particularly if we're going to test
internationalization.

>+    def test_export_xml(self):
>+        reference_string = """<?xmlversion="1.0"encoding="UTF-8"?><clientConfig><emailProviderid=""><id>1</id><lastUpdateDatetime>2009-09-3000:24:54</lastUpdateDatetime><createdDatetime>2009-09-3000:24:54</createdDatetime><approved>False</approved><invalid>False</invalid><emailProviderId></emailProviderId><displayName>NetZeroEmail</displayName><displayShortName>netzero</displayShortName><incomingServertype="imap"><hostname>hostname_in</hostname><port>143</port><socketType>SSL</socketType><usernameForm></usernameForm><authentication>plain</authentication></incomingServer><outgoingServer><hostname>hostname_out</hostname><port>25</port><socketType>None</socketType><usernameForm>%EMAILLOCALPART%</usernameForm><authentication>plain</authentication><addThisServer>False</addThisServer><useGlobalPreferredServer>False</useGlobalPreferredServer></outgoingServer><settingsPageUrl>http://www.referencematerial.com/</settingsPageUrl><settingsPageLanguage>en</settingsPageLanguage><flaggedAsIncorrect>False</flaggedAsIncorrect><flaggedByEmail></flaggedByEmail><confirmations>0</confirmations><problems>0</problems></emailProvider></clientConfig>"""

Less than 80 characters, please.  ;)
It might read nicer if you put newlines in the reference string, and
removed them with the same re.sub as you use to remove them from the
config_xml.

>Index: fixtures/xml_testdata.json
>+[{"pk": 1, "model": "config.domain", "fields": {"status": "", "votes": 1, "config": 1, "name": "test.com"}}, {"pk": 1, "model": "config.configaudit", "fields": {"outgoing_use_global_preferred_server": false, "incoming_socket_type": "SSL", "outgoing_port": 25, "flagged_by_email": "", "flagged_as_incorrect": false, "email_provider_id": "", "incoming_authentication": "plain", "id": 1, "display_name": "NetZero Email", "outgoing_add_this_server": false, "outgoing_socket_type": "None", "created_datetime": "2009-09-30 00:24:54", "outgoing_authentication": "plain", "invalid": false, "incoming_hostname": "hostname_in", "settings_page_url": "http://www.referencematerial.com/", "outgoing_username_form": "%EMAILLOCALPART%", "display_short_name": "netzero", "_audit_change_type": "I", "problems": 0, "confirmations": 0, "_audit_timestamp": "2009-09-30 00:24:54", "approved": false, "incoming_port": 143, "last_update_datetime": "2009-09-30 00:24:54", "incoming_username_form": "", "settings_page_language": "en", "outgoing_hostname": "hostname_out", "incoming_type": "imap"}}, {"pk": 1, "model": "config.config", "fields": {"outgoing_use_global_preferred_server": false, "incoming_socket_type": "SSL", "outgoing_port": 25, "flagged_by_email": "", "flagged_as_incorrect": false, "email_provider_id": "", "incoming_authentication": "plain", "display_name": "NetZero Email", "outgoing_add_this_server": false, "outgoing_socket_type": "None", "created_datetime": "2009-09-30 00:24:54", "outgoing_authentication": "plain", "invalid": false, "incoming_hostname": "hostname_in", "settings_page_url": "http://www.referencematerial.com/", "outgoing_username_form": "%EMAILLOCALPART%", "display_short_name": "netzero", "problems": 0, "confirmations": 0, "approved": false, "incoming_port": 143, "last_update_datetime": "2009-09-30 00:24:54", "incoming_username_form": "", "settings_page_language": "en", "outgoing_hostname": "hostname_out", "incoming_type": "imap"}}]

This also needs a lot of newlines, and indentation.  ;)

Thanks,
Blake.
Attachment #403979 - Flags: review?(bwinton) → review-
Assignee: nobody → LouieDinh
Attached patch Revised Patch (obsolete) — Splinter Review
Added django_nose as a dependency. Apparently this needs Django-1.1 because I needed to upgrade before it would work.

First Patch - Try #2
Attachment #403979 - Attachment is obsolete: true
Attachment #404992 - Flags: review?(bwinton)
Attachment #404992 - Flags: review?(david.ascher)
Attachment #404992 - Flags: review?(bwinton)
Attachment #404992 - Flags: review+
Comment on attachment 404992 [details] [diff] [review]
Revised Patch

>Index: settings.py
>+#TODO: Clean this up after eric's patch for local settings
>+   os.path.join(os.path.abspath("./"),"fixtures/"), 

There's a trailing space on the above line.

>Index: README
> Step 0: Prerequisites
>+    Django-1.1
>     easy_install django-openid-auth
>     easy_install python-openid
>+    pip install django-nose (might have to run easy_install pip first)

If we're using pip to install django-nose, should we also use it to install django-openid-auth and python-openid?
(I actually just used the one line:
    pip install django python-openid django-openid-auth django-nose
and it all seemed to work nicely.)

>Index: tests/test_xml.py
>+# -*- coding: utf-8 -*-

Much better.  :)

It will be good to get some more tests added, and this moves us closer to that.

So, fix the things I mentioned above, and you get an r+ from me.

Later,
Blake.
Comment on attachment 404992 [details] [diff] [review]
Revised Patch

Great first step.  r=davida, with a few comments:

1) I think we probably need a mechanisms to let gozer (who runs the production instance) know about the requirements for prerequisite software.  Gozer, do you have a favorite mechanism for that?

This tests export from a JSON persisted fixture, which is great.  A follow up test which would be good is a test of the _import_ mechanism (from the file format that's in the sibling repo http://svn.mozilla.org/mozillamessaging.com/sites/autoconfig.mozillamessaging.com/trunk/).  

A particularly simple but interesting test would be a round-trip test which imported from the static files being served from e.g. http://live.mozillamessaging.com/autoconfig/aim.com through import, through export, and comparing the outputs to the original input.
Attachment #404992 - Flags: review?(david.ascher) → review+
Blocks: 521173
(In reply to comment #5)
> (From update of attachment 404992 [details] [diff] [review])
> Great first step.  r=davida, with a few comments:
> 
> 1) I think we probably need a mechanisms to let gozer (who runs the production
> instance) know about the requirements for prerequisite software.  Gozer, do you
> have a favorite mechanism for that?

Just filing bug requiring those packages (ideally with specific version needed/wanted) to be packaged and installed on the ispdb systems would be fine.
Just minor cosmetic fixes to get ready for checkin.
Attachment #404992 - Attachment is obsolete: true
Keywords: checkin-needed
Comment on attachment 405414 [details] [diff] [review]
[checked-in] Patch-v.3 

Committed revision 53423.
Attachment #405414 - Attachment description: Patch-v.3 → [checked-in] Patch-v.3
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Component: ispdb → ISPDB Server
Product: Mozilla Messaging → Webtools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: