Skip to content

Commit

Permalink
Merge pull request #20 from geonexus/develop
Browse files Browse the repository at this point in the history
new: dev: Adding more unit tests
  • Loading branch information
Fernando López Aguilar committed Nov 4, 2014
2 parents c51d5d0 + edb8ff5 commit 62375d6
Show file tree
Hide file tree
Showing 25 changed files with 919 additions and 152 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[report]
omit =
cloto/tests/*
cloto/settings.py
160 changes: 160 additions & 0 deletions .gitchangelog.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
##
## Format
##
## ACTION: [AUDIENCE:] COMMIT_MSG [@TAG ...]
##
## Description
##
## ACTION is one of 'chg', 'fix', 'new'
##
## Is WHAT the change is about.
##
## 'chg' is for refactor, small improvement, cosmetic changes...
## 'fix' is for bug fixes
## 'new' is for new features, big improvement
##
## SUBJECT is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc'
##
## Is WHO is concerned by the change.
##
## 'dev' is for developpers (API changes, refactors...)
## 'usr' is for final users (UI changes)
## 'pkg' is for packagers (packaging changes)
## 'test' is for testers (test only related changes)
## 'doc' is for doc guys (doc only changes)
##
## COMMIT_MSG is ... well ... the commit message itself.
##
## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic'
##
## 'refactor' is obviously for refactoring code only
## 'minor' is for a very meaningless change (a typo, adding a comment)
## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...)
## 'wip' is for partial functionality but complete subfunctionality.
##
## Example:
##
## new: usr: support of bazaar implemented
## chg: re-indentend some lines @cosmetic
## new: dev: updated code to be compatible with last version of killer lib.
## fix: pkg: updated year of licence coverage.
## new: test: added a bunch of test around user usability of feature X.
## fix: typo in spelling my name in comment. @minor
##
## Please note that multi-line commit message are supported, and only the
## first line will be considered as the "summary" of the commit message. So
## tags, and other rules only applies to the summary. The body of the commit
## message will be displayed in the changelog with minor reformating.


##
## ``ignore_regexps`` is a line of regexps
##
## Any commit having its full commit message matching any regexp listed here
## will be ignored and won't be reported in the changelog.
##
ignore_regexps = [
r'@minor', r'!minor',
r'@cosmetic', r'!cosmetic',
r'@refactor', r'!refactor',
r'@wip', r'!wip',
r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[p|P]kg:',
r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[d|D]ev:',
r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$',
]


##
## ``replace_regexps`` is a dict associating a regexp pattern and its replacement
##
## It will be applied to get the summary line from the full commit message.
##
## Note that you can provide multiple replacement patterns, they will be all
## tried. If None matches, the summary line will be the full commit message.
##
replace_regexps = {
## current format (ie: 'chg: dev: my commit msg @tag1 @tag2')

r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$':
r'\4',
}


## ``section_regexps`` is a list of 2-tuples associating a string label and a
## list of regexp
##
## Commit messages will be classified in sections thanks to this. Section
## titles are the label, and a commit is classified under this section if any
## of the regexps associated is matching.
##
section_regexps = [
('New', [
r'^[nN]ew\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Changes', [
r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Fix', [
r'^[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),

## ('Other', None ## Match all lines
## ),

]


## ``body_split_regexp`` is a regexp
##
## Commit message body (not the summary) if existing will be split
## (new line) on this regexp
##
body_split_regexp = r'\n(?=\w+\s*:)'


## ``tag_filter_regexp`` is a regexp
##
## Tags that will be used for the changelog must match this regexp.
##
tag_filter_regexp = r'^[0-9]+\.[0-9]+(\.[0-9]+)?$'
## tag_filter_regexp = r'^release-[0-9]+\.[0-9]+(\.[0-9]+)?$'

## ``unreleased_version_label`` is a string
##
## This label will be used as the changelog Title of the last set of changes
## between last valid tag and HEAD if any.
unreleased_version_label = "1.3.0 (unreleased)"


## ``output_engine`` is a callable
##
## This will change the output format of the generated changelog file
##
## Available choices are:
##
## - rest_py
##
## Legacy pure python engine, outputs ReSTructured text.
## This is the default.
##
## - mustache(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mustache/*.tpl``.
## Requires python package ``pystache``.
## Examples:
## - mustache("markdown")
## - mustache("restructuredtext")
##
## - makotemplate(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mako/*.tpl``.
## Requires python package ``mako``.
## Examples:
## - makotemplate("restructuredtext")
##
output_engine = rest_py
#output_engine = mustache("restructuredtext")
#output_engine = mustache("markdown")
#output_engine = makotemplate("restructuredtext")
45 changes: 45 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Changelog
=========

1.2.0 (2014-10-31)
------------------

New
~~~

- Allowed host added into automatic installer. Now default local IP
address is added to settings.py. [Guillermo Jimenez Prieto]

- Adding documentation to github. [geonexus]

Changes
~~~~~~~

- Indentation fix. [Guillermo Jimenez Prieto]

Fix
~~~

- Server version is now based on a string value and it is needed to
change value in configuration.py before each release. [geonexus]

- Changing version float in server information to string value. Fixing
some words mistaken. [geonexus]

- Adding HTTP TRACE TRACK methods disabling instructions. [geonexus]

- Adding PyClips requirement to README.md. [geonexus]

- Updating databases to mysql commands. [geonexus]

- Updating databases to mysql commands. [geonexus]

- Adding titles to rst files. [geonexus]

- Adding documentation to github. [geonexus]

- Adding documentation to github. [geonexus]

- Adding documentation to github. [geonexus]


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ After finishing you must configure cloto configuration and some apache settings.
### Configuration - Cloto
---------------------

Before starting the rule engine, you should edit configuration.py located at cloto folder.
Before starting the rule engine, you should edit settings.py located at cloto folder or in /etc/sysconfig/fiware-cloto.cfg.
Constants you need to complete are:

- All in # OPENSTACK CONFIGURATION: Openstack information (If you provide this information in the install
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
# -*- encoding: utf-8 -*-
#
# Copyright 2014 Telefónica Investigación y Desarrollo, S.A.U
Expand Down Expand Up @@ -31,6 +32,7 @@ source ENV/bin/activate
mkdir -m 777 /var/log/fiware-cloto
pip install -r requirements.txt
echo "no" | python manage.py syncdb
export DJANGO_SETTINGS_MODULE=cloto.settings_tests
coverage run --source=cloto manage.py test

if [ ! $1 = "travis_build" ];
Expand Down
13 changes: 7 additions & 6 deletions cloto/OrionClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
__author__ = 'gjp'
import json
import requests
from configuration import CONTEXT_BROKER_URL, NOTIFICATION_URL, NOTIFICATION_TIME, NOTIFICATION_TYPE
from django.conf import settings
import constants
from cloto.log import logger

Expand All @@ -48,13 +48,14 @@ def contextBrokerSubscription(self, tenantId, serverId):
'"attributes": [' \
'"cpu",' \
'"mem"],' \
'"reference": "' + NOTIFICATION_URL + '/' + tenantId + 'servers/' + serverId + '",' \
'"reference": "' + settings.NOTIFICATION_URL + '/' + \
tenantId + 'servers/' + serverId + '",' \
'"duration": "P1M",' \
'"notifyConditions": [' \
'{"type": "' + NOTIFICATION_TYPE + '",' \
'"condValues": ["' + NOTIFICATION_TIME + '"]}]}'
'{"type": "' + settings.NOTIFICATION_TYPE + '",' \
'"condValues": ["' + settings.NOTIFICATION_TIME + '"]}]}'

r = self.client.post(CONTEXT_BROKER_URL + "/subscribeContext", data, headers=headers)
r = self.client.post(settings.CONTEXT_BROKER_URL + "/subscribeContext", data, headers=headers)

if r.status_code == 200:
decoded = json.loads(r.text.decode())
Expand All @@ -73,7 +74,7 @@ def contextBrokerUnSubscription(self, cbSubscriptionId, serverId):
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = json.dumps("{\"subscriptionId\": \"%s\"}" % cbSubscriptionId)

r = self.client.post(CONTEXT_BROKER_URL + "/unsubscribeContext", data, headers=headers)
r = self.client.post(settings.CONTEXT_BROKER_URL + "/unsubscribeContext", data, headers=headers)
if r.status_code == 200:
logger.info("Server %s was unsubscribed from Context Broker.--- HTTP Response: %d"
% (serverId, r.status_code))
Expand Down
60 changes: 0 additions & 60 deletions cloto/configuration.py

This file was deleted.

2 changes: 1 addition & 1 deletion cloto/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import clips
import requests

from configuration import RABBITMQ_URL, LOGGING_PATH, DB_CHARSET, DB_HOST, DB_NAME, DB_PASSWD, DB_USER
from cloto.settings import RABBITMQ_URL, LOGGING_PATH, DB_CHARSET, DB_HOST, DB_NAME, DB_PASSWD, DB_USER
from constants import SERVERID
from log import logger
LOGGER_COMPONENT = 'ENVIRONMENT'
Expand Down
11 changes: 8 additions & 3 deletions cloto/environmentManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

from circus.process import Process

from configuration import ENVIRONMENTS_PATH, INSTALLATION_PATH, DB_HOST, DB_CHARSET, DB_USER, DB_NAME, DB_PASSWD
from cloto.settings import ENVIRONMENTS_PATH, INSTALLATION_PATH, DB_HOST, DB_CHARSET, DB_USER, \
DB_NAME, DB_PASSWD, SETTINGS_TYPE
from log import logger


Expand All @@ -50,9 +51,13 @@ def exit_program(*args):

while (True):
try:
conn = mysql.connect(charset=DB_CHARSET, use_unicode=True, host=DB_HOST,
conn = None
if SETTINGS_TYPE == 'production':
conn = mysql.connect(charset=DB_CHARSET, use_unicode=True, host=DB_HOST,
user=DB_USER, passwd=DB_PASSWD, db=DB_NAME)
#conn = lite.connect(INSTALLATION_PATH + 'cloto.db')
elif SETTINGS_TYPE == "test":
import sqlite3 as lite
conn = lite.connect(INSTALLATION_PATH + 'cloto.db')
cursor = conn.cursor()
cursor.execute('SELECT * FROM cloto.cloto_tenantinfo')
data = cursor.fetchall()
Expand Down
Loading

0 comments on commit 62375d6

Please sign in to comment.