Web App Development - Django - TDD Django Tutorial - 24th April 2013



Starting with Django-: 24th April 2013


·         Checking the Django version, the version installed is 1.4.3 .

·         Deleted the old Django 1.4.3 files from the C:\Django folder.

·         Deleted the django folder from C:\Python27\Lib\site-packages

·         In the C:\Django folder ran “python setup.py install”

·         Install successful, no error thrown.

·         Installation checked via Command line – “import django;print (django.get_version())
·         Result Version 1.5.1 – Successful install

·         Installed Selenium for running tests in C:\Python27 via “pip install selenium”. Had to run command thrice as on previous 2 occasions, the installation “timed-out”.

·         Selenium installation successful.

·         Installed Mock for testing in C:\Python27 via “pip install mock”. In the end it said, installation successful.

·         Opened command prompt, went to Python module and ran “import selenium” and “import mock”, no error thrown.

·         Moved to C:\Sites and ran “django-admin.py startproject hnk” and it ran without hitch. 

 Checked the folder C:\Sites and it had created the app there with the same set of files as mentioned. 

Started the web server by moving into C:\Sites\hnk and running “python manage.py runserver” . No error thrown. 

  Opened the browser and went to localhost:8000  and it showed the welcome page – “Congratulations, It worked”.

·         In C:\Sites\hnk ran “python manage.py startapp fts” . This created a new folder inside “hnk”, called the “fts” and now the directory structure of “hnk” looks like -:
·         hnk
·         |-- fts
·         |   |-- __init__.py
·         |   |-- models.py
·         |   |-- tests.py
·         |   `-- views.py
·         |-- manage.py
·         `-- hnk
·             |-- __init__.py
·             |-- settings.py
·             |-- urls.py
·             `-- wsgi.py

·         Opened C:\Sites\hnk\fts\tests.py and edited it with the following code-:

·         from django.test import LiveServerTestCase
·         from selenium import webdriver
·          
·         class PollsTest(LiveServerTestCase):
·          
·             def setUp(self):
·                 self.browser = webdriver.Firefox()
·                 self.browser.implicitly_wait(3)
·          
·             def tearDown(self):
·                 self.browser.quit()
·          
·             def test_can_create_new_poll_via_admin_site(self):
·                 # Gertrude opens her web browser, and goes to the admin page
·                 self.browser.get(self.live_server_url + '/admin/')
·          
·                 # She sees the familiar 'Django administration' heading
·                 body = self.browser.find_element_by_tag_name('body')
·                 self.assertIn('Django administration', body.text)
·          
·                 # TODO: use the admin site to create a Poll
·                 self.fail('finish this test')
·          

Comments

Post a Comment

Popular posts from this blog

Coursera - CS 101 - Completed